@extends('layouts.default') @section('main')
<link rel="stylesheet" href="/css/uniform.css" />
<link rel="stylesheet" href="/css/select2.css" />
<div id="content">
	<div id="content-header">
		<div id="breadcrumb">
			<a href="{{url('home')}}" title="返回首页" class="tip-bottom"><i
				class="icon-home"></i> 首页</a> <a href="#" class="current">广告管理</a>
		</div>
	</div>
	<div class="container-fluid">
		<div class="row-fluid">
			<div class="span12">
				@if(in_array('add',$actions)) <a href="{{url('ad/create')}}"><button
						class="btn">新增</button></a> @endif

                    <form action="{{url('ad/search')}}" method="post">
                        <table>
                            <tr>
                                <th>
                                    <label >广告名称 :</label>
                                </th>
                                <th>
                                    <div class="controls">
                                        <input type="text" class="span11" name="title"  placeholder="广告名称" />
                                    </div>
                                </th>


                                <th>
                                    <label >广告类型 :</label>
                                </th>
                                <th>
                                    <div class="controls">
                                        <select  name="type" class="span11">
                                            <option value="">请选择</option>
                                            <option value="index_banner">首页轮播图</option>
                                            <option value="web_ovo_videolist">活动视频列表页广告图</option>
                                            <option value="web_ovo_convenelists">活动召集列表页广告图</option>
                                            <option value="web_ovo_trailerlist">活动预告列表页广告图</option>
                                            <option value="web_ovo_index">ovo首页轮播图</option>
                                            <option value="phone_rshow_banner">手机路演轮播图</option>
                                            <option value="app_index">app首页的轮播广告</option>
                                            <option value="app_middle_index">app首页的中间广告</option>
                                        </select>
                                    </div>
                                </th>

                                <th>
                                    <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                    <div class="controls">
                                        <button type="submit" class="btn btn-info">查询</button>
                                    </div>
                                </th>
                            </tr>
                        </table>
                    </form>

				<div class="widget-box">
					<div class="widget-title">
						<span class="icon"><i class="icon-th"></i></span>
						<h5>广告管理</h5>
					</div>
					<div class="widget-content nopadding">
						<table class="table table-bordered table-striped">
							<thead>
								<tr>
									<th>广告图片</th>
									<th>广告名称</th>
									<th>广告类型</th>
									<th>开始时间</th>
									<th>结束时间</th>
									<th>活动详情</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
								@foreach($ads as $key => $ad)
								<tr class="gradeX">
                                    <td><a title="点击查看大图" href="{{url('ad/image?aid='.$ad->id)}}"><img src="{{getImage($ad->image)}}" width="50" height="50"/></a></td>
                                    <td title="{{$ad->title}}">{{cut_str($ad->title,10)}}</td>
									<td>{{$ad->type_name}}</td>
                                    <td>@if(0!=$ad->start_time){{date('Y-m-d H:i:s',$ad->start_time)}} @endif</td>
                                    <td>@if(0!=$ad->expired_time){{date('Y-m-d H:i:s',$ad->expired_time)}} @endif</td>
									<td><a href="{{action('AdController@getAddetail',['aid'=>$ad->id])}}">点击查看</a></td>
									<td class="center">@if(in_array('edit',$actions)) <a
										data-original-title="编辑" class="tip"
										href="{{action('AdController@getEdit',['aid'=>$ad->id])}}"><i
											class="icon-pencil"></i></a> @endif
										@if(in_array('delete',$actions)) <a data-original-title="删除"
										data-toggle="modal" class="tip ad_delete"
										ad_id="{{$ad->id}}" href="#myAlert"><i
											class="icon-remove"></i></a> @endif
									</td>
								</tr>
								@endforeach
							</tbody>
						</table>
					</div>
				</div><?php echo $ads->render();?>
      </div>
		</div>
	</div>
</div>
<div>
	<div id="myAlert" class="modal hide">
		<div class="modal-header">
			<button data-dismiss="modal" class="close" type="button">×</button>
			<h3>提示</h3>
		</div>
		<div class="modal-body">
			<p>确认删除这条数据吗？</p>
		</div>
		<div class="modal-footer">
			<a data-dismiss="modal" class="btn btn-primary" href="javascript:void(0);">确定</a>
			<a data-dismiss="modal" class="btn" href="javascript:void(0);">取消</a>
		</div>
	</div>
	<form action="{{url('ad/delete')}}" method="post"
		id="adForm">
		<input type="hidden" name="aid" value="0">
	</form>
</div>
<script src="/js/matrix.tables.js"></script>
<script src="/js/common.js"></script>
<script>
$(".ad_delete").click(function(){
	var ad_id = $(this).attr("ad_id");
	$("input[name='aid']").val(ad_id);
});
$(".btn-primary").click(function(){
	var ad_id = $("input[name='aid']").val();
	if(ad_id == 0){
		alert('参数异常');
		return;
	}
	ajaxRequest($('#adForm').serializeArray(),$('#adForm').attr('action'),function(data){
		if(data.status){
			window.location.href = data.forwardUrl;
		}else{
			alert(data.message);
		}
	});
});
</script>
@stop
